using System;
using System.Collections;
using System.Collections.Generic;
using Main.Event;
using UnityEngine;
using ZSW.Framework;


namespace Main.UI
{
    [RequireComponent(typeof(UI_Slot_Bag))]
    public class UI_ActionBarButton : ZSWF_InitMonoBehaviour
    {
        public KeyCode keyCode;
        public UI_Slot_Bag slot_bag;
        public bool canUse = true;
        public override void Init()
        {
            base.Init();

            MainEventSystem.UpdateGameStateEvent += OnUpdateGameState;
        }

        private void OnUpdateGameState(GameState state)
        {
            this.canUse = state == GameState.GamePlay;
        }

        private void Update()
        {
            if (Input.GetKeyDown(keyCode) && canUse)
            {
                // 存在物品时
                if (slot_bag.CurrentItemDetails != null)
                {
                    slot_bag.inventoryUI.OnSlotClick(slot_bag.slotIndex);
                }
            }
        }
    }

}
